package com.temp.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import com.temp.annotation.LoginNameUnique;
import com.temp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

public class LoginNameUniqueValidator implements ConstraintValidator<LoginNameUnique, String> {

    @Autowired
    private UserService userService;

    @Override
    public boolean isValid(String loginName, ConstraintValidatorContext context) {
        return userService.checkLoginNameUnique(loginName);
    }
}
